package com.cy.web.common.util;

import org.springframework.http.HttpRequest;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

public class ServletUtil {

    /**通过 RequestContextHolder 类型获取请求属性*/
    public static ServletRequestAttributes getServletRequestAttributes(){
        return (ServletRequestAttributes)
                RequestContextHolder.getRequestAttributes();
    }

    public static HttpServletRequest getRequest(){
        return getServletRequestAttributes().getRequest();
    }
}
